package com.education.controller.selectTestPeper;

import com.education.pojo.Grade;
import com.education.pojo.Subject;
import com.education.pojo.TestPaper;
import com.education.service.impl.SelectTestPeperImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by Administrator on 2018/4/23.
 */
@Controller
@CrossOrigin(origins = "*",maxAge = 3600)
public class SelectTestPeperController {
    @Autowired
    private SelectTestPeperImpl selectTestPeper;
    @RequestMapping("/selectTestPeper")
    @ResponseBody
    public List<TestPaper> selectTestPeperlist(HttpServletRequest req){
        //获取前台传的值
        //获取学科
        String sname = req.getParameter("sname");
        //获取年级
        String gname = req.getParameter("gname");
        //获取题型选择
        String tpname = req.getParameter("tpname");

        System.out.println(sname);
        System.out.println(gname);
        System.out.println(tpname);
        //获取学科的ID
       Subject subject= selectTestPeper.getSubjectId(sname);
        System.out.println(subject.getsId());
        //获取年级的ID
        Grade grade = selectTestPeper.getGradeId(gname);
        System.out.println(grade.getgId());
//        //获取试卷名
        List<TestPaper> list = selectTestPeper.getTestPeper(grade.getgId(),subject.getsId(),tpname);

        return list;
    }
}
